#include <Common/Log.h>
#include <D3dDdi/Log/AdapterFuncsLog.h>

std::ostream& operator<<(std::ostream& os, const D3DDDIARG_CREATEDEVICE& data)
{
	auto& log = Compat::LogStruct(os)
		<< data.hDevice
		<< data.Interface
		<< data.Version
		<< data.pCallbacks
		<< data.pCommandBuffer
		<< data.CommandBufferSize
		<< Compat::out(Compat::array(data.pAllocationList, data.AllocationListSize))
		<< data.AllocationListSize
		<< Compat::out(Compat::array(data.pPatchLocationList, data.PatchLocationListSize))
		<< data.PatchLocationListSize
		<< Compat::out(data.pDeviceFuncs)
		<< Compat::hex(data.Flags.Value);

	if (D3dDdi::g_umdVersion >= D3D_UMD_INTERFACE_VERSION_WIN7)
	{
		log << Compat::hex(data.CommandBuffer);
	}

	return log;
}

std::ostream& operator<<(std::ostream& os, D3DDDICAPS_TYPE data)
{
	switch (data)
	{
		LOG_CONST_CASE(D3DDDICAPS_DDRAW);
		LOG_CONST_CASE(D3DDDICAPS_DDRAW_MODE_SPECIFIC);
		LOG_CONST_CASE(D3DDDICAPS_GETFORMATCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETFORMATDATA);
		LOG_CONST_CASE(D3DDDICAPS_GETMULTISAMPLEQUALITYLEVELS);
		LOG_CONST_CASE(D3DDDICAPS_GETD3DQUERYCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETD3DQUERYDATA);
		LOG_CONST_CASE(D3DDDICAPS_GETD3D3CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETD3D5CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETD3D6CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETD3D7CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETD3D8CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETD3D9CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODEGUIDCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODEGUIDS);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODERTFORMATCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODERTFORMATS);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODECOMPRESSEDBUFFERINFOCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODECOMPRESSEDBUFFERINFO);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODECONFIGURATIONCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETDECODECONFIGURATIONS);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORDEVICEGUIDCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORDEVICEGUIDS);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORRTFORMATCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORRTFORMATS);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORRTSUBSTREAMFORMATCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORRTSUBSTREAMFORMATS);
		LOG_CONST_CASE(D3DDDICAPS_GETVIDEOPROCESSORCAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETPROCAMPRANGE);
		LOG_CONST_CASE(D3DDDICAPS_FILTERPROPERTYRANGE);
		LOG_CONST_CASE(D3DDDICAPS_GETEXTENSIONGUIDCOUNT);
		LOG_CONST_CASE(D3DDDICAPS_GETEXTENSIONGUIDS);
		LOG_CONST_CASE(D3DDDICAPS_GETEXTENSIONCAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETGAMMARAMPCAPS);
		LOG_CONST_CASE(D3DDDICAPS_CHECKOVERLAYSUPPORT);
		LOG_CONST_CASE(D3DDDICAPS_DXVAHD_GETVPDEVCAPS);
		LOG_CONST_CASE(D3DDDICAPS_DXVAHD_GETVPOUTPUTFORMATS);
		LOG_CONST_CASE(D3DDDICAPS_DXVAHD_GETVPINPUTFORMATS);
		LOG_CONST_CASE(D3DDDICAPS_DXVAHD_GETVPCAPS);
		LOG_CONST_CASE(D3DDDICAPS_DXVAHD_GETVPCUSTOMRATES);
		LOG_CONST_CASE(D3DDDICAPS_DXVAHD_GETVPFILTERRANGE);
		LOG_CONST_CASE(D3DDDICAPS_GETCONTENTPROTECTIONCAPS);
		LOG_CONST_CASE(D3DDDICAPS_GETCERTIFICATESIZE);
		LOG_CONST_CASE(D3DDDICAPS_GETCERTIFICATE);
		LOG_CONST_CASE(D3DDDICAPS_GET_ARCHITECTURE_INFO);
		LOG_CONST_CASE(D3DDDICAPS_GET_SHADER_MIN_PRECISION_SUPPORT);
		LOG_CONST_CASE(D3DDDICAPS_GET_MULTIPLANE_OVERLAY_CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GET_MULTIPLANE_OVERLAY_FILTER_RANGE);
		LOG_CONST_CASE(D3DDDICAPS_GET_MULTIPLANE_OVERLAY_GROUP_CAPS);
		LOG_CONST_CASE(D3DDDICAPS_GET_SIMPLE_INSTANCING_SUPPORT);
		LOG_CONST_CASE(D3DDDICAPS_GET_MARKER_CAPS);
	}

	return os << "D3DDDICAPS_" << static_cast<DWORD>(data);
}

std::ostream& operator<<(std::ostream& os, const D3DDDIARG_GETCAPS& data)
{
	return Compat::LogStruct(os)
		<< data.Type
		<< data.pInfo
		<< data.pData
		<< data.DataSize;
}

std::ostream& operator<<(std::ostream& os, const FORMATOP& data)
{
	return Compat::LogStruct(os)
		<< data.Format
		<< Compat::hex(data.Operations)
		<< Compat::hex(data.FlipMsTypes)
		<< Compat::hex(data.BltMsTypes)
		<< data.PrivateFormatBitCount;
}
